import request from '../utils/request.js'
//用户数据示例

//群数据示例


function RestApi() {

}

RestApi.prototype.findFriends = function (user) {
    var friendList = users.filter(v => v.uuid != user.uuid);
    return friendList;
}

RestApi.prototype.findGroups = function (user) {
    var groupList = groups.filter(v => v.userList.find(id => id == user.uuid));
    return groupList;
}

RestApi.prototype.findUser = function (username, password) {
    let user = users.find(user => (user.name === username && user.password === password));
    if (user) {
        return {
            uuid: user.uuid,
            avatar: user.avatar,
            name: user.name
        };
    }
    return user;
}

RestApi.prototype.findGroupById = function (groupId) {
    var group = groups.find(group => (group.uuid == groupId));
    return group;
};


RestApi.prototype.ThreeUserStore = function (friendId) {

    return user;
},


    RestApi.prototype.findGroupMembers = function (groupId) {
        let members = [];
        let group = groups.find(v => v.uuid == groupId);
        users.map(user => {
            if (group.userList.find(v => v == user.uuid)) {
                members.push(user)
            }
        });
        return members;
    }

export default new RestApi();
